<template>
  <div class="result-detail">
    <div class="message-header">
      <button class="back-button" @click="$emit('back')">
        <svg viewBox="0 0 24 24" width="16" height="16">
          <path fill="currentColor" d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/>
        </svg>
        返回搜索结果
      </button>
    </div>
    <div class="message-content">
      <h3 class="search-title">{{ result.title }}</h3>
      <a :href="result.url" target="_blank" class="search-url">{{ result.url }}</a>
      <p class="search-snippet">{{ result.snippet }}</p>
    </div>
    <div class="message-meta">
      <span class="timestamp">{{ formatTime(new Date().toISOString()) }}</span>
    </div>
  </div>
</template>

<script setup>
defineProps({
  result: {
    type: Object,
    required: true
  }
});

defineEmits(['back']);

const formatTime = (isoString) => {
  const date = new Date(isoString);
  return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
};
</script>

<style scoped>
.result-detail {
  background: #f8f9fa;
  padding: 16px;
}

.message-header {
  margin-bottom: 20px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #f8f9fa;
  border: 1px solid #eaecef;
  border-radius: 6px;
  color: #4e5969;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-button:hover {
  background: #f0f2f5;
}

.message-content {
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
}

.search-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.4;
}

.search-url {
  display: block;
  margin-bottom: 12px;
  color: #4e6ef2;
  text-decoration: none;
  font-size: 13px;
  word-break: break-all;
  opacity: 0.8;
}

.search-url:hover {
  text-decoration: underline;
  opacity: 1;
}

.search-snippet {
  margin: 0;
  color: #4e5969;
  line-height: 1.6;
  font-size: 14px;
}

.message-meta {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #eaecef;
}

.timestamp {
  color: #8590a6;
  font-size: 12px;
}

@media (max-width: 768px) {
  .result-detail {
    padding: 12px;
  }

  .search-title {
    font-size: 16px;
  }
}
</style> 